import { db } from "@/storage";

export default {
  namespaced: true,
  state: () => ({
    collapsed: false,
    asiderWidth: "260px",
    loading: false,
    // 上锁
    appConfig: db.get('appConfig') || {},
  }),
  getters: {},
  mutations: {
    toggleCollapsed(state) {
      state.collapsed = !state.collapsed;
    },
    changeLoading(state, loading) {
        state.loading = loading
    },
    changeMainValue(state, data) {
        Object.assign(state.appConfig, data)
        db.set('appConfig', state.appConfig)
    },
  },
  actions: {
    changeMainName({ commit }, { route, title }) {
        return new Promise((resovle) => {
            commit('changeMainValue', {mainName: route, title, isLock: true})
            resovle(route)
        })
    }
  },
};
